// 使用 as const 获取字面量类型
const typeList = [
    'SET_MACRO_FOLDER_STRUCTURE',
    'SET_EDITOR_ACTIVE_TAB',
    'ADD_LOGS',
    'UPDATE_ONE_MACRO_EXTRA',
    'SET_VARIABLE_LIST',
    'START_PLAYING',
    'SET_PLAYER_STATE',
    'UPDATE_ONE_MACRO_EXTRA',
    'STOP_PLAYING',
    'UPDATE_UI',
    'SET_CSV_LIST',
    'SET_SCREENSHOT_LIST',
    'SET_VISION_LIST',
    'CLEAR_LOGS',
    'SET_NO_DISPLAY_IN_PLAY',
    'EDIT_TEST_CASE',
    'SET_CURRENT_MACRO',
    'UPDATE_COMMANDS',
    'UPDATE_CONFIG',
    'UPDATE_SELECTED_COMMAND',
    'UPDATE_COMMAND',
    'START_INSPECTING',
    'STOP_INSPECTING',
    'SELECT_COMMAND',
    'SET_FROM',
    'SET_IS_LOADING_MACROS',
    'SET_MACROS_EXTRA',
    'EDIT_NEW_TEST_CASE',
    'SET_EDITING',
    'UPDATE_PROXY',
    'DONE_INSPECTING',
    'STOP_INSPECTING_SUCCESS',
    'TOGGLE_RECORDER_SKIP_OPEN',
    'INSERT_COMMAND',
    'APPEND_COMMAND',
    'SET_OCR_IN_DESKTOP_MODE',
    'CLEAR_SCREENSHOTS',
    'START_RECORDING_SUCCESS',
    'STOP_RECORDING_SUCCESS',
    'SAVE_EDITING_AS_EXISTED',
    'SAVE_EDITING_AS_NEW',
    'START_INSPECTING_SUCCESS',
    'DUPLICATE_COMMAND',
    'REMOVE_COMMAND',
    'UPDATE_EDITING',
    'CUT_COMMAND',
    'COPY_COMMAND',
    'PASTE_COMMAND',
    'MOVE_COMMANDS',
    'NORMALIZE_COMMANDS',
    'SET_TEST_CASES',
    'RENAME_TEST_CASE',
    'REMOVE_TEST_CASE',
    'ADD_SCREENSHOT',
    'SET_SOURCE_ERROR',
    'SET_SOURCE_CURRENT',
    'SET_IS_DRAGGING_COMMAND',
    'SET_REPLAY_SPEED_OVERRIDE_TO_FAST_MODE',
    'SET_MACROS_QUERY',
    'SET_INDEX_TO_INSERT_RECORDED',
    'ADD_VISION',
    'CLEAR_VISIONS'
] as const;

// 使用类型推导生成类型
type TypeListToActionType<T extends readonly string[]> = {
    [K in T[number]]: K;
};

// 获取实际类型
type ActionTypes = TypeListToActionType<typeof typeList>;

// 实现 reducer 并指定返回类型
const actionTypes = typeList.reduce<ActionTypes>(
    (m: any, t) => {
        m[t] = t;
        return m;
    },
    {} as ActionTypes // 初始值类型断言
);

export default actionTypes;